<template>
    <el-dialog v-model="open" title="加资产" width="510px">
        <el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px">
            <el-form-item label="类型">
                <el-select v-model="formData.tokenType" placeholder="请选择" @change="onSubmit">
                    <el-option label="USDT" :value="0"> </el-option>
                    <el-option label="USDH" :value="1"> </el-option>
                    <el-option label="USDF" :value="2"> </el-option>
                    <el-option label="HF" :value="3"> </el-option>
                    <el-option label="NFTV" :value="4"> </el-option>
                    <el-option label="HF2" :value="5"> </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="数量" prop="amount">
                <el-input v-model="formData.amount" placeholder="请输入数量" />
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button type="primary" :loading="loading" @click="onSubmit('formData')">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script setup>
import { reactive, ref, defineExpose, defineEmits } from "vue";
import { addBalance } from "@/api";
import { ElMessageBox, ElMessage } from "element-plus";
const emit = defineEmits(["onSubmit"]);
const formRef = ref();
const open = ref(false);
const formData = reactive({
    amount: "",
    Id: "",
    tokenType: 0,
});
const formRules = {
    amount: [{ required: true, message: "请输入数量", trigger: "change" }],
};
const loading = ref(false);
const onSubmit = async () => {
    try {
        const a = await formRef.value.validate().catch(() => null);
        if (!a) return;
        open.value = false;
        const res = await addBalance(formData);
        if (res.data.code == 20) {
            ElMessage({
                message: "成功",
                type: "success",
            });
        }
        emit("onSubmit");
    } catch (error) {}
};
const show = (row) => {
    open.value = true;
    formData.id = row.Id;
    formData.amount = "";
    formData.tokenType = 0;
};
defineExpose({
    show,
});
</script>
<style lang="scss" scoped>
.right {
    overflow: auto;
}

.el-pagination {
    padding: 15px;
    float: right;
}
</style>